<?php
/**
 * 后端contoller的公共父类
 * @author Zhang Hao
 */
namespace app\common\base;

use Yii;
use yii\web\Controller;
use app\common\behaviors\CommonBehavior;
use app\common\behaviors\ControllerBehavior;

class CommonController extends Controller
{
    public $rules = [];
    public $timeNow;

    public function behaviors()
    {
        return \yii\helpers\ArrayHelper::merge(parent::behaviors(), [
            'corsFilter' => [
                'class' => \yii\filters\Cors::className(),
                'actions' => [
                    '*' => Yii::$app->request->allowRequestMethods,
                ],
            ],
            'commonBehavior' => [
                'class' => CommonBehavior::className(),
            ],
            'controllerBehavior' => [
                'class' => ControllerBehavior::className(),
            ],
        ]);
    }

    public function init()
    {
        parent::init();
        $this->timeNow = Yii::$app->params['timeNow'];
        $this->enableCsrfValidation = false;
    } 
}